import { createSlice } from "@reduxjs/toolkit";
import useraxios from "../../model/useraxios";
export const userSlice = createSlice({
  name: "userinfo",
  initialState: {
    account: "",
    userpwd: "",
    id: "",
  },
  reducers: {
    add: (state: any, action) => {
      return {
        account: action.payload.account,
        userpwd: action.payload.userpwd,
        id: action.payload.id,
      };
    },
  },
});
export const { add } = userSlice.actions;


// export  const asyncAddListItem=(payload:any)=>  (dispatch:any)=>new  Promise(async (resolve)=>{

//     let  {data:list} = await  userModel.query({username:payload.username});
//     if(list.length){
//         resolve({
//             code:0,
//             msg:"该用户名已经存在"
//         })
//     }else{
//         let  {data} =  await  userModel.add(payload);
//         dispatch(addListItem(data));
//         resolve({
//             code:1,
//             msg:"新增成功"
//         })

//     }

//  })
export default userSlice.reducer;
